import time
import os


def write_pid(path):
    output=open(path,'w')
    output.write(str(os.getpid()))
    output.close()

def remove_pid(path):
    if os.path.isfile(path):
        os.remove(path)

def show_message(message, path=""):
    time_now=time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
    print time_now,message

    if path!="":
        write_file(path,time_now+" "+message)

def write_file(path,message):
    output=open(path,'a')
    output.write(message+'\n')
    output.close()

